let arr = ['a', 'b', 'c', 'd', 'e']

Array.prototype.my_splice = function (start, len, ...args) {
  let start = args.shift() === undefined ? 0 : args.shift()
  let len = args.shift()
  
  const res = [], newArr = []
  for (let i = start; i < start + len; i++) {
    res.push(this[start])
    start++
  }

  for (let j = 0; j < this.length; j++) {
    if (j < start || j >= start + len) newArr.push(this[j]) 
    if (j === start) newArr.push(...args)  
  }

  while (this.length) {
    this.pop()
  }
  this.push(...newArr)
  return res
}

const res = arr.splice()
console.log(res);
